#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;

#define in read()
#define pii pair<int,int>
#define fi first
#define se second
#define FILE(x) freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout);
#define pb push_back

int read(){
	int x = 0,sgn = 1;char ch = getchar();
	for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;
	for(;isdigit(ch);ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);
	return x*sgn;
}

const int N = 5010;

vector<int> G[N];
int f[N][N][2],siz[N],tmp[N][2],n,deg[N];

void dfs(int x,int p){
	if(G[x].size() == 1 && p){f[x][0][0] = 0; f[x][1][1] = 0;siz[x] = 1;return;}
	f[x][0][0] = 0; f[x][0][1] = 0;
	for(int y : G[x]){
		if(y == p) continue;
		dfs(y,x);
		memset(tmp,0x3f,sizeof(tmp));
		for(int i = 0;i <= siz[x];i++){
			for(int j = 0;j <= siz[y];j++){
				tmp[i+j][0] = min(tmp[i+j][0],min(f[x][i][0] + f[y][j][0],f[x][i][0] + f[y][j][1] + 1));
				tmp[i+j][1] = min(tmp[i+j][1],min(f[x][i][1] + f[y][j][0] + 1,f[x][i][1] + f[y][j][1]));
			}
		}
		siz[x] += siz[y];
		for(int i = 0;i <= siz[x];i++)
			for(int j = 0;j < 2;j++)
				f[x][i][j] = tmp[i][j];
	}
}

int main (){
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	n = in; if(n == 2) return puts("-1"),0;
	for(int i = 1;i < n;i++){
		int u = in,v = in;
		G[u].pb(v); G[v].pb(u); deg[u]++;deg[v]++;
	}memset(f,0x3f,sizeof f);
	int rt = 1; while(deg[rt] == 1) rt++;
	dfs(rt,0);
	printf("%d\n",min(f[rt][siz[rt] / 2][0],f[rt][siz[rt] / 2][1]));
	return 0;
}

